<%@ page import="com.cruxconsultores.rh.Empleado" %>
<!DOCTYPE html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'candidato.label', default: 'Candidato')}" />
		<title><g:message code="default.create.label" args="[entityName]" /></title>
	</head>
	<body>
		<a href="#create-empleado" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div class="nav" role="navigation">
			<ul>
				<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
				<li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
			</ul>
		</div>
		<div id="create-empleado" class="content scaffold-create" role="main">
			<h1><g:message code="default.create.label" args="[entityName]" /></h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<g:hasErrors bean="${empleadoInstance}">
			<ul class="errors" role="alert">
				<g:eachError bean="${empleadoInstance}" var="error">
				<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>
				</g:eachError>
			</ul>
			</g:hasErrors>
			<g:form action="save" >
				<fieldset class="form">
					<g:render template="form"/>
				</fieldset>
				<fieldset class="buttons">
					<g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" />
				</fieldset>
			</g:form>
		</div>

    <g:javascript>

        function tienePareja(){

            if (document.getElementById('pareja').checked){
                document.getElementById('detallePareja').disabled=false;
            }else{
                document.getElementById('detallePareja').disabled=true;
                document.getElementById('detallePareja').value="";
            }
        }

        function updateSelect(name,data,keepFirstOption,selected,presentNullAsThis) {
            var rselect = $('#'+name).get(0);
            if (data) {
                // remove old options
                var start = (keepFirstOption) ? 0 : -1;
                var i = rselect.length;
                while (i > start) {
                    rselect.remove(i);
                    i--;
                }

                // add new options

                $.each(data,function() {

                    var i = rselect.options.length
                    rselect.options[i] = new Option(
                            (presentNullAsThis && this.nombre == null) ? presentNullAsThis : this.nombre,
                            this.id
                    );
                    if (this.id == selected) rselect.options[i].selected = true;
                });

                var xx = "[]";
                if (name == 'canton') updateSelect('distrito',xx,true,false,'default');
            }
        }
    </g:javascript>



	</body>
</html>
